package com.zmx.controller;

import com.zmx.aop.MyLog;
import com.zmx.entity.ScheduleJob;
import com.zmx.service.ScheduleJobService;
import com.zmx.utils.RUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 定时任务(ScheduleJob)表控制层
 *
 * @author makejava
 * @since 2020-10-21 09:43:29
 */
@RestController
@RequestMapping("schedule/job")
public class ScheduleJobController {
    /**
     * 服务对象
     */
    @Resource
    private ScheduleJobService scheduleJobService;

    @RequestMapping("/list")
    public RUtils scheduleList(int limit,int offset,String search,String order){
        return scheduleJobService.scheduleJobList(limit,offset,search,order);
    }

    @RequestMapping("/save")
    public  RUtils  save(@RequestBody ScheduleJob scheduleJob){
        return  scheduleJobService.saveScheduleJob(scheduleJob);
    }
    @RequestMapping("/del")
    public  RUtils  delete(@RequestBody List<Long> ids) {
        return  scheduleJobService.deleteScheduleJob(ids);
    }
    //修改

    @RequestMapping("/info/{jobId}")
    public   RUtils info(@PathVariable("jobId") long jobId){
        System.out.println(jobId);
        return  scheduleJobService.scheduleInfo(jobId);
    }

    @RequestMapping("/update")
    public  RUtils   update(@RequestBody ScheduleJob scheduleJob) {
        return  scheduleJobService.updateScheduleJob(scheduleJob);
    }
    //修改结束


    @RequestMapping("/pause")
    public RUtils pause(@RequestBody List<Long> ids) {
        return  scheduleJobService.pauseScheduleJob(ids);
    }
    @RequestMapping("/resume")
    public  RUtils  resume(@RequestBody List<Long> ids) {
        return  scheduleJobService.resumeScheduleJob(ids);
    }
    @RequestMapping("/run")
    public  RUtils  run(@RequestBody List<Long> ids) {
        return  scheduleJobService.runOneScheduleJob(ids);
    }

}